//
//  XZSingInView.m
//  Teecloud
//
//  Created by 贵州贵农网络科技有限公司 on 2018/7/19.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "XZSingInView.h"

@interface XZSingInView ()
@property (weak, nonatomic) IBOutlet UIView *alertView;

@property (weak, nonatomic) IBOutlet UILabel *showLabel;

@end

@implementation XZSingInView

- (void)show:(NSString *)msg{
    self.showLabel.text = msg;
    [UIView animateWithDuration:0.25 animations:^{
        UIWindow *rootWindow = [UIApplication sharedApplication].keyWindow;
        [rootWindow addSubview:self];
        [self animationAlert:self.alertView];
    }];
}

- (void)hide
{
    [UIView animateWithDuration:0.25 animations:^{
        [self removeFromSuperview];
    }];
    
}

- (void)animationAlert:(UIView *)view
{
    CAKeyframeAnimation *popAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    popAnimation.duration = 0.4;
    popAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.01f, 0.01f, 1.0f)],
                            [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1f, 1.0f)],
                            [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9f, 1.0f)],
                            [NSValue valueWithCATransform3D:CATransform3DIdentity]];
    popAnimation.keyTimes = @[@0.0f, @0.5f, @0.75f, @1.0f];
    popAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
                                     [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
                                     [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    [view.layer addAnimation:popAnimation forKey:nil];
    
}
- (IBAction)iknowButtonClick:(UIButton *)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(sininSuccess:)]) {
        [self.delegate sininSuccess:self];
    }
}


@end
